import { storage, browser, tabs } from 'wxt/browser'
import { defineBackground } from 'wxt/background'

// Define state
let autoState = ''
let wasEnabledOnLastCheck = null
let registeredContextMenus = null
let wasLastColorSchemeDark = null

// Initialize
export const init = defineBackground({
    main() {
      // Initialization code here
      // This runs when the extension starts
      loadData()
      setupListeners()
    }
  })


// Event listeners
function setupListeners() {
    browser.alarms.onAlarm.addListener(alarmListener)
    browser.commands.onCommand.addListener(onCommand)
    // Other listeners...
  }  

// Event handlers
async function alarmListener(alarm: browser.alarms.Alarm) {
    if (alarm.name === 'auto-time-alarm') {
      await loadData()
      handleAutomationCheck()
    }
  }
  
  async function onCommand(command: string) {
    // Handle commands
  }
  
  // Other functions from the Extension class...
  async function loadData() {
    // Load data from storage
  }
  
  function handleAutomationCheck() {
    // Automation check logic
  }

// Export other necessary functions that might be called from other parts of the extension
export async function toggleActiveTab() {
    // Toggle active tab logic
  }
  
  export async function changeSettings(settings: Partial<UserSettings>, onlyUpdateActiveTab = false) {
    // Change settings logic
  }  